 <!DOCTYPE html>
<html>
<head lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>加载bing地图</title>
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 95%;overflow: hidden;margin:0;}
        #l-map{height:100%;width:100%;float:left;border-right:2px solid #bcbcbc;}
        #r-result{height:100%;width:20%;float:left;}

    </style>
	<link href='./css/bootstrap.min.css' rel='stylesheet' />
    <link href='./css/bootstrap-responsive.min.css' rel='stylesheet' />
    <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
    <script type="text/javascript" src="../libs/SuperMap.Include.js"></script>
    <script type="text/javascript" src="js/iConnector/iConnectorBing.js"></script>
</head>
<body>
<div id="toolbar">
    <input type="button" class="btn" value="创建点密度专题图" onclick="addThemeGraduatedSymbol()" />
    <input type="button" class="btn" value="移除点密度专题图" onclick="removeTheme()" />
</div>
    <div id='mapDiv' style="position:relative; width:1500px; height:800px;top:10px"></div>
</body>
</html>

<script type="text/javascript">
    //初始化bing地图
    var map =  new Microsoft.Maps.Map(document.getElementById("mapDiv"),
            {
                credentials: "lreUBEESaL4bfklHiTpp~O8b_Njm__lkjPi2a2V_IFA~An6RmV3tm1L_xD_Pp28ih0yJxJFZzJva435V6zcJX2mhD7D9_j9XnQRPB8yqdpqQ",
                center: new Microsoft.Maps.Location(25.5, -182.5),

                zoom: 3,
                mapTypeId: Microsoft.Maps.MapTypeId.road
            });

    var tilelayer,vectorlayer;
    var host = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : 'http://' + document.location.host;
    url = host + "/iserver/services/map-china400/rest/maps/China";

    //添加点密度专题图
    function addThemeGraduatedSymbol() {
        vectorlayer&&map.entities.remove(vectorlayer);
        //初始化专题图制作请求服务类
        var themeService = new SuperMap.REST.ThemeService(url,
                        {eventListeners:{"processCompleted": themeCompleted, "processFailed": themeFailed}}),
                graStyle = new SuperMap.REST.ThemeGraduatedSymbolStyle({
                    positiveStyle: new SuperMap.REST.ServerStyle({
                        markerSize: 50,
                        markerSymbolID: 0,
                        lineColor: new SuperMap.REST.ServerColor(255,165,0),
                        fillBackColor: new SuperMap.REST.ServerColor(255,0,0)
                    })
                }),
                themeGraduatedSymbol = new SuperMap.REST.ThemeGraduatedSymbol({
                    expression: "SMAREA",
                    baseValue: 3000000000000,
                    graduatedMode: SuperMap.REST.GraduatedMode.CONSTANT,
                    flow: new SuperMap.REST.ThemeFlow({
                        flowEnabled: true
                    }),
                    style: graStyle
                }),
                themeParameters = new SuperMap.REST.ThemeParameters({
                    themes: [themeGraduatedSymbol],
                    datasetNames: ["China_Province_pg"],
                    dataSourceNames: ["China"]
                });
        //向iserver发送请求
        themeService.processAsync(themeParameters);
    }
    //生成专题图后将其叠加到 bing 地图上面
    function themeCompleted(themeEventArgs) {
        if(themeEventArgs.result.resourceInfo.id) {
            var id =  themeEventArgs.result.resourceInfo.id;
            vectorlayer = SuperMap.Web.iConnector.Bing.getTileLayer(url,{layersID:id});
            map.entities.push(vectorlayer);

        }
    }

    function themeFailed(serviceFailedEventArgs) {
        alert(serviceFailedEventArgs.error.errorMsg);
    }
    function removeTheme(){
        map.entities.remove(vectorlayer);

    }


</script>